package com.chidopi.cdf.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AreaTag extends SimpleTagSupport {
	private static Logger logger = LoggerFactory.getLogger(AreaTag.class);
	private String op;
	private String area;

	public void setOp(String op) {
		this.op = op;
	}

	public void setArea(String area) {
		this.area = area;
	}

	@Override
	public void doTag() throws JspException, IOException {
		logger.debug("op=" + this.op + "; area=" + this.area);
		JspWriter out = this.getJspContext().getOut();
		if ("key".equalsIgnoreCase(this.area)) {
			if (!"insert".equalsIgnoreCase(this.op)) out.print("disabled");
		}
		if ("data".equalsIgnoreCase(this.area)) {
			if ("delete".equalsIgnoreCase(this.op)) out.print("disabled");
		}
	}
}
